<script setup lang='ts'>
// 自定义 规则
interface Item {
    id: string,
    addtime: string,
    alias: string,
}

import {  ref, } from 'vue';
import { onShow } from '@dcloudio/uni-app'
import { https } from '@/api/api';
import { showToast } from '@/public';
import Tabbar from '@/components/tabbar/index.vue'
//const { } = defineProps<Props>();

/**
 * @property 变量
 */
// 团队列表
const teamList = ref<Array<Item>>([]);
// 添加团队
const isAddTem = ref<boolean>(false)
/**
 * @property  所有请求以api开头 如:apiDataInfo
 */
// 获取团队列表
const apiShareList = async () => {
    const res = await https({
        mode: 'marker',
        name: 'apiGetShare'
    })
    // showToast(res.msg);
    if (res.code !== 0) return showToast(res.msg);;
    teamList.value = res.data.list
}
/**
 * @property 自定义事件 以事件名开头 如: clickButton,inputDev
 */
const clickDelete = async (id: string) => {
    const res = await https({
        mode: 'marker',
        name: 'apiDelShare',
        data: {
            share: id + ''
        }
    })
    showToast(res.data.msg)
    if (res.code !== 0) return;
    teamList.value = teamList.value.filter(item => item.id !== id);
}
/**
 * @property 内置方法
 */
onShow(async () => {
    apiShareList();
})

</script>
<template>
    <div class="w-[100vw] h-[100vh] bg-[#f2f2f2]">
        <up-empty mode="history" v-if="teamList.length <= 0" />
        <scroll-view scroll-y class="w-[100%] h-[100%]">
            <div class="w-[100%] pl-3 pr-3 h-[100%]">
                <div class="w-[100%] h-100 b-rd-3 bg-[#fff] mt-3 flex fra pl-3 pr-3" v-for="item in teamList"
                    :key="item.id">
                    <div class="flex flex-col flex-1">
                        <text class="font-size-28">{{ item.alias }}</text>
                        <text class="font-size-24 c-[#9D9D9D]">分享时间：{{ item.addtime }}</text>
                    </div>
                    <text class="c-red font-size-28" @click="clickDelete(item.id)">删除</text>
                    <!-- <up-button type="primary" :plain="true" text="删除" shape="circle" :customStyle="{color:'red',border:'red',width:'200rpx'}"></up-button> -->
                </div>
            </div>
        </scroll-view>
        <!-- <up-collapse accordion>
            <up-collapse-item :title="item.name" v-for="(item, i) in teamList" :key="i">
                <text class="font-size-28" v-for="(v, i) in item.children" :key="i">{{ v.name }}</text>
            </up-collapse-item>
        </up-collapse>
        <div class="fixed bottom-0 pl-3 pr-3 h-100 pb-3 w-[100%]">
            <Bottom text="添加团队" @click="isAddTem = true" />
        </div> -->
    </div>
    <Tabbar type="user" />
    <!-- <AddTem :is-show="isAddTem" @close="isAddTem = false" @add-con="apiTeamList" /> -->
</template>
<style lang="scss" scoped></style>